import requests, json
from consts import USER_INFO_API_URL, FANS_LIST_API_URL
from utils.create_header import create_header


def get_user_info_api(uid, cookie):
    url = USER_INFO_API_URL + f'?uid={uid}'
    headers = create_header(cookie)
    response = requests.get(url, headers=headers)
    data = json.loads(response.text)
    result = None
    if data['ok']:
        result = data['data']['user']
    return result

def get_fans_list_api(uid, page, cookie):
    url = FANS_LIST_API_URL + f'?relate=fans&page={page}&uid={uid}'
    headers = create_header(cookie)
    response = requests.get(url, headers=headers)
    data = json.loads(response.text)
    return data
